<template>
  <view class="post-list">
    <view v-for="item in myPosts" :key="item.id" class="post-item">
      <view class="header">
        <text class="school">{{ item.schoolName }}</text>
        <text class="status" :class="item.status">{{ statusMap[item.status] }}</text>
      </view>
      <view class="info">
        <text>📍 {{ item.location }}</text>
        <text>👥 需要{{ item.needCount }}人</text>
        <text>📅 {{ item.createdAt }}</text>
      </view>
      <view class="actions">
        <button @click="editPost(item.id)">编辑</button>
        <button @click="deletePost(item.id)">删除</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      statusMap: {
        draft: '草稿',
        pending: '审核中',
        published: '已发布',
        closed: '已截止'
      },
      myPosts: [
        {
          id: 1,
          schoolName: '阳光希望小学',
          location: '云南丽江',
          needCount: 3,
          createdAt: '2023-07-20',
          status: 'published'
        }
      ]
    }
  },
  methods: {
    editPost(id) {
      uni.navigateTo({ url: `/pages/post/create?id=${id}` })
    },
    async deletePost(id) {
      // 删除逻辑
    }
  }
}
</script>

<style lang="scss" scoped>
.post-list {
  padding: 20rpx;
  
  .post-item {
    background: #fff;
    border-radius: 12rpx;
    padding: 25rpx;
    margin-bottom: 20rpx;
    
    .header {
      display: flex;
      justify-content: space-between;
      margin-bottom: 20rpx;
      
      .school {
        font-size: 30rpx;
        color: #2c3e50;
      }
      
      .status {
        font-size: 24rpx;
        &.published { color: #5bc0eb; }
        &.pending { color: #f1c40f; }
        &.closed { color: #999; }
      }
    }
    
    .info text {
      display: block;
      margin-bottom: 10rpx;
      color: #666;
    }
    
    .actions {
      display: flex;
      gap: 20rpx;
      margin-top: 20rpx;
      
      button {
        flex: 1;
        background: #f0f0f0;
        color: #666;
        border-radius: 30rpx;
      }
    }
  }
}
</style> 